package edu.mse.camel.client.uml.collab.emflistener;

import org.eclipse.emf.ecore.EObject;

import edu.mse.camel.client.core.events.model.ModelUpdateEvent;
import edu.mse.camel.client.core.events.model.ModelUpdateEvent.KIND;

/**
 * @author darpan
 *
 */
public class UMLContentAdapter extends CachingContentAdapter {

	public UMLContentAdapter(EObject model) {
		super(model);
	}
	
//	@Override
//	protected void handleAdds(Notification notification, Object notifier) {
//		if (notifier instanceof EObject) {
//			ModelID modelID = modelIDCache.getID((EObject) notifier);
//			if (modelID != null) {
//				Object newValueObject = notification.getNewValue();
//				ModelUpdateEvent me = EventUtil.createModelEvent(notification,
//						modelID, ModelUpdateEvent.KIND.UML, ModelUpdateEvent.EVENT_TYPE.ADD);
//				if (newValueObject instanceof EObject) {
//					int featureID = notification.getFeatureID(notification.getFeature().getClass());
//					if (featureID != UMLPackage.PACKAGE__OWNED_TYPE) { // specific to UML models only
//						cacheElement((EObject) newValueObject);
//						Resource resource =  
//							new XMLResourceImpl(null);//URI.createURI("platform:/resource/P1/uml.xml"));
//						resource.getContents().add(EcoreUtil.copy((EObject) newValueObject));
//						try {
//							ByteArrayOutputStream baos = new ByteArrayOutputStream();
//							resource.save(baos, null);
//							me.setByteArray(baos.toByteArray());
//							me.setFeatureID(featureID);
//							me.setElementModelID(modelIDCache.getID((EObject) newValueObject));
//							publishEvent(me);
//						} catch (IOException e) {
//							e.printStackTrace();
//						}
//					}
//				}
//			}
//		}
//	}

	@Override
	protected KIND getKind() {
		return ModelUpdateEvent.KIND.UML;
	}
	
}
